package com.qf.smartdevice.service.impl;

import com.qf.smartdevice.mapper.SysMenuMapper;
import com.qf.smartdevice.pojo.SysMenu;
import com.qf.smartdevice.service.SysMenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author 王博康
 * @version 1.0
 * @project devicemanagementsystem
 * @description: TODO
 * @date 2022/3/28 1:19 星期一
 */
@Service
@Transactional
public class SysMenuServiceImpl implements SysMenuService {

    private SysMenuMapper sysMenuMapper;

    @Autowired
    public void setSysMenuMapper(SysMenuMapper sysMenuMapper) {
        this.sysMenuMapper = sysMenuMapper;
    }

    @Override
    public List<SysMenu> findAll() {

        return sysMenuMapper.findAll();
    }

    @Override
    public List<SysMenu> findAllLeftMenu() {
        List<SysMenu> leftMenuList = sysMenuMapper.findAll().stream().filter(sysMenu -> {
             return sysMenu.getMenuType().equalsIgnoreCase("M");
        }).collect(Collectors.toList());
        return leftMenuList;
    }
}
